var dsBridge = require('dsbridge')
export default {
  /** dsBridge 插件 */
  dsSync (name, data) {
    data = data
    return dsBridge.call(name, data, { msg: 'callSyn' })
  },
  dsCall (name, data, callback = function () { }) {
    data = data
    dsBridge.call(name, data, callback)
  },
  dsReg (name, callback = function () { }) {
    dsBridge.register(name, callback)
  },
  /** jsBridge 封装 */
  /* jsCall(name, data, callback) {
    setupWebViewJavascriptBridge(bridge => {
      bridge.callHandler(name, data, callback)
    })
  },
  jsReg(name, callback) {
    setupWebViewJavascriptBridge(bridge => {
      bridge.registerHandler(name, (data, responseCallback) => {
        callback(data, responseCallback)
      })
    })
  },*/
  /** 原生方法 */
  iosCall (name, data, callback = function () { }) {
    data = data
    if (window.webkit && window.webkit.messageHandlers) {
      window.webkit.messageHandlers[name].postMessage(data)
      callback()
    }
  },
  iosReg (name, callback = function () { }) {
    window[name] = callback
  }
}
